/**
 * 还没按解决时间区间筛选
 */

package com.xidian.zhiancloud.controller.dangerWorkTicket;


import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.service.dangerWorkTicket.WorkTicketStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/workTicketStatistics")
public class WorkTicketStatisticsController extends BaseController {
    @Autowired
    private WorkTicketStatisticsService workTicketStatisticsService;

    /**
     * 按作业类型进行统计，返回每种作业票类型、对应的数量，以及导出接口
     */
    @GetMapping("/statisticsByType")
    public ResultDTO statisticsByType(
            @RequestParam(value = "companyId", required = true) Long companyId,
            @RequestParam(value = "startTime", required = false) Date startTime,
            @RequestParam(value = "endTime", required = false) Date endTime) {
        return ResultDTO.successOf(workTicketStatisticsService.statisticsByType(companyId, startTime, endTime), GeneralResponseEnums.SUCCESS);
    }

    /**
     * 按作业区域/地点进行统计
     */
    @GetMapping("/statisticsByOrganizationId")
    public ResultDTO statisticsByPositionId(
            @RequestParam(value = "companyId", required = true) Long companyId,
            @RequestParam(value = "startTime", required = false) Date startTime,
            @RequestParam(value = "endTime", required = false) Date endTime) {
        return ResultDTO.successOf(workTicketStatisticsService.statisticsByPositionId(companyId, startTime, endTime), GeneralResponseEnums.SUCCESS);
    }
}
